package com.newtouch.bxzs.business.train.controller;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.newtouch.bxzs.business.config.MyLog;
import com.newtouch.bxzs.business.train.model.bo.ExaminationPaperSetExaminationQuestionListBO;
import com.newtouch.bxzs.business.train.model.bo.ExaminationQuestionListBO;
import com.newtouch.bxzs.business.train.model.bo.ExaminationQuestionOptionListBO;
import com.newtouch.bxzs.business.train.model.bo.QuestionBankSetExaminationQuestionListBO;
import com.newtouch.bxzs.business.train.model.vo.ExaminationPaperSetExaminationQuestionListVO;
import com.newtouch.bxzs.business.train.model.vo.ExaminationQuestionListVO;
import com.newtouch.bxzs.business.train.model.vo.ExaminationQuestionOptionListVO;
import com.newtouch.bxzs.business.train.model.vo.ModifyExaminationQuestionInfoVO;
import com.newtouch.bxzs.business.train.model.vo.QuestionBankSetExaminationQuestionListVO;
import com.newtouch.bxzs.business.train.service.ExaminationQuestionService;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 试题管理的接口
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021年2月5日</td>
 * <td>dongjinlin</td>
 * <td>Create</td>
 * </tr>
 * </table>
 * 
 * @author dongjinlin
 * 
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "试题管理")
@RestController
@RequestMapping("/examinationsQuestionController")
@SuppressWarnings("unchecked")
public class ExaminationQuestionController {

	/** 静态变量：系统日志 */
	private static final Log logger = LogFactory.getLog(ExaminationQuestionController.class);

	@Autowired
	private ExaminationQuestionService examinationQuestionService;

	/**
	 * 查询题库设置试题列表
	 * 
	 * @param questionBankSetExaminationQuestionListVO
	 * @return
	 */
	@ApiOperation(value = "查询题库设置试题列表")
	@PostMapping("/getQuestionBankSetExaminationQuestionList")
	public BaseResponse<QuestionBankSetExaminationQuestionListBO> getQuestionBankSetExaminationQuestionList(
			@RequestBody @ApiParam(name = "questionBankSetExaminationQuestionListVO", value = "查询题库设置试题列表VO类", required = true) QuestionBankSetExaminationQuestionListVO questionBankSetExaminationQuestionListVO) {
		logger.info("查询题库设置试题列表");
		return RespGenerator.returnOK(examinationQuestionService
				.getQuestionBankSetExaminationQuestionList(questionBankSetExaminationQuestionListVO));
	}

	/**
	 * 查询试卷设置试题列表
	 * 
	 * @param questionBankSetExaminationQuestionListVO
	 * @return
	 */
	@ApiOperation(value = "查询试卷设置试题列表")
	@PostMapping("/getExaminationPaperSetExaminationQuestionList")
	public BaseResponse<ExaminationPaperSetExaminationQuestionListBO> getExaminationPaperSetExaminationQuestionList(
			@RequestBody @ApiParam(name = "questionBankSetExaminationQuestionListVO", value = "查询题库设置试题列表VO类", required = true) ExaminationPaperSetExaminationQuestionListVO examinationPaperSetExaminationQuestionListVO) {
		logger.info("查询试卷设置试题列表");
		return RespGenerator.returnOK(examinationQuestionService
				.getExaminationPaperSetExaminationQuestionList(examinationPaperSetExaminationQuestionListVO));
	}

	/**
	 * 查询试题列表
	 * 
	 * @param examinationQuestionListVO
	 * @return
	 */
	@ApiOperation(value = "查询试题列表")
	@PostMapping("/getExaminationQuestionList")
	@MyLog(systemFunctionName = "试题管理", systemFunctionUrl = "/examinationsQuestionController/getExaminationQuestionList", userOperationType = 4, userOperationSummary = "查询试题列表")
	public BaseResponse<ExaminationQuestionListBO> getExaminationQuestionList(
			@RequestBody @ApiParam(name = "examinationQuestionListVO", value = "查询试题列表VO类", required = true) ExaminationQuestionListVO examinationQuestionListVO) {
		logger.info("查询试题列表");
		return RespGenerator.returnOK(examinationQuestionService.getExaminationQuestionList(examinationQuestionListVO));
	}

	/**
	 * 创建、修改试题信息
	 * 
	 * @param modifyExaminationQuestionInfo
	 * @return
	 */
	@ApiOperation(value = "创建或修改试题基本信息")
	@PostMapping("/modifyExaminationQuestionInfo")
	@MyLog(systemFunctionName = "试题管理", systemFunctionUrl = "/examinationsQuestionController/modifyExaminationQuestionInfoVO", userOperationType = 5, userOperationSummary = "创建或修改试题基本信息")
	public BaseResponse<String> modifyExaminationQuestionInfo(
			@RequestBody @ApiParam(name = "modifyExaminationQuestionInfo", value = "创建、修改试题信息VO类", required = true) ModifyExaminationQuestionInfoVO modifyExaminationQuestionInfo) {
		logger.info("创建或修改试题基本信息");
		return RespGenerator
				.returnOK(examinationQuestionService.modifyExaminationQuestionInfo(modifyExaminationQuestionInfo));
	}

	/**
	 * 删除试题
	 * 
	 * @param examinationQuestionIds
	 * @return
	 */
	@ApiOperation(value = "删除试题")
	@PostMapping("/deleteExaminationQuestion")
	@MyLog(systemFunctionName = "试题管理", systemFunctionUrl = "/examinationsQuestionController/deleteExaminationQuestion", userOperationType = 3, userOperationSummary = "删除试题")
	public BaseResponse<Integer> deleteExaminationQuestion(
			@RequestBody @ApiParam(name = "examinationQuestionIds", value = "试题id集合", required = true) List<String> examinationQuestionIds) {
		logger.info("删除试题");
		return RespGenerator
            .returnOK(examinationQuestionService.deleteExaminationQuestion(examinationQuestionIds));
	}

	/**
	 * 获取该试题的试题选项列表
	 * 
	 * @param examinationQuestionOptionListVO
	 * @return
	 */
	@ApiOperation(value = "查询该试题的试题选项列表")
	@PostMapping("/getExaminationQuestionsOptionList")
	public BaseResponse<ExaminationQuestionOptionListBO> getExaminationQuestionsOptionList(
			@RequestBody @ApiParam(name = "examinationQuestionOptionListVO", value = "查询该试题的试题选项列表", required = true) ExaminationQuestionOptionListVO examinationQuestionOptionListVO) {
		logger.info("查询该试题的试题选项列表");
		return RespGenerator
				.returnOK(examinationQuestionService.getExaminationQuestionOptionList(examinationQuestionOptionListVO));
	}

//	/**
//	 * 创建、修改试题选项
//	 * 
//	 * @param modifyExaminationQuestionOptionVO
//	 */
//	@ApiOperation(value = "创建、修改试题选项")
//	@PostMapping("/modifyExaminationQuestionOption")
//	@MyLog(systemFunctionName = "试题管理", systemFunctionUrl = "/examinationsQuestionController/modifyExaminationQuestionOption", userOperationType = 5, userOperationSummary = "创建试题选项")
//	public BaseResponse<String> modifyExaminationQuestionOption(
//			@RequestBody @ApiParam(name = "modifyExaminationQuestionOptionVO", value = "试题选项类VO", required = true) ModifyExaminationQuestionOptionVO modifyExaminationQuestionOptionVO) {
//		logger.info("创建、修改试题选项");
//		return RespGenerator.returnOK(
//				examinationQuestionService.modifyExaminationQuestionOption(modifyExaminationQuestionOptionVO));
//	}

	/**
	 * 删除试题选项
	 * 
	 * @param examinationQuestionOptionIds
	 */
	@ApiOperation(value = "删除试题选项")
	@PostMapping("/deleteExaminationQuestionOptions")
	@MyLog(systemFunctionName = "试题管理", systemFunctionUrl = "/examinationsQuestionController/deleteExaminationQuestionOptions", userOperationType = 3, userOperationSummary = "删除试题选项")
	public BaseResponse<Integer> deleteExaminationQuestionOptions(
			@RequestBody @ApiParam(name = "deleteExaminationQuestionOptions", value = "试题选项类VO", required = true) List<String> examinationQuestionOptionIds) {
		logger.info("删除试题选项");
		return RespGenerator.returnOK(examinationQuestionService.deleteExaminationQuestionOptions(examinationQuestionOptionIds));
	}
}
